<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="google" value="notranslate">
  <link rel="shortcut icon" href="static/favicon.ico">
  <title>Scratch 3.0 Player</title>
  <script src="../js/jquery.min.js"></script>
  <script src="../js/common.js?v=27"></script>
  <script>
    var workId = urlParams('workId')
    var workUrl = urlParams('workUrl')
    window.scratchConfig = {
      cloudData:{
        enable: true,
        id: workId, //云变量ID
        api: window.location.hostname + "/api/websocket/scratch/cloudData" //云变量API地址
      },
      projectInfo: {//作品信息
        authorUsername: "",
        authorAvatar: './static/avatar.png',
      },
      stageArea: {
        scale: window.innerWidth / 480, //自适应屏幕大小
        width: 480,
        height: 360,
        showControl: true,
        showLoading: false,
        fullscreenButton:{ //全屏按钮
          show: true,
          handleBeforeSetStageUnFull(){ //退出全屏前的操作
            var event = new CustomEvent('scratchUnFullScreen');
            window.parent.document.dispatchEvent(event);
            return true
          },
          handleBeforeSetStageFull(){ //全屏前的操作
            var event = new CustomEvent('scratchFullScreen');
            window.parent.document.dispatchEvent(event);
            setTimeout(()=>{
              window.scratch.setFullScreen(true)
            },100)
            return false
          }
        },
        startButton:{ //开始按钮
          show: true,
          handleBeforeStart(){ //开始前的操作
            return true
          }
        },
        stopButton:{ // 停止按钮
          show: true,
          handleBeforeStop(){ //停止前的操作
            return true
          }
        }
      },
      handleVmInitialized: (vm) => {
        window.vm = vm
      },
      handleDefaultProjectLoaded: () => {
        if(workUrl){
          window.scratch.loadProject(workUrl, () => {
            window.scratch.setCloudId(workUrl)
            vm.runtime.start()
          })
        }else if(workId){
          getWorkInfo(workId, function (info) {
            window.scratch.loadProject(info.workFileKey_url, () => {
              window.scratch.setCloudId(workId)
              vm.runtime.start()
            })
          })
        }
      }
    }
  </script>
</head>

<body>
  <div id="scratch">
  </div>
</body>

<script type="text/javascript" src="lib.min.js"></script>
<script type="text/javascript" src="chunks/player.js"></script>
<script>

</script>

</html>